<template>
  <view class="page" v-if="shenheStatus != 1 || !shenheAliStatus">
    <view class="content">
      <view class="menu">
        <view
          @click="index = item.id"
          :class="['menuItem', index === item.id ? 'active' : '']"
          v-for="item of list"
          :key="item.id"
        >
          <view class="name">
            {{ item.name }}
          </view>
        </view>
      </view>

      <view class="img" v-if="index === 1">
        <image
          show-menu-by-longpress
          :src="conf.wechat_qrcode"
          mode="widthFix"
        ></image>
        <view class="imgdes">保存收款码到相册</view>
      </view>

      <view class="img" v-if="index === 2">
        <image
          show-menu-by-longpress
          :src="conf.alipay_qrcode"
          mode="widthFix"
        ></image>
        <view class="imgdes">保存收款码到相册</view>
      </view>

      <view class="list" v-if="index === 3">
        <view class="bank_card">
          <view class="number">{{ conf.bank_card_id }}</view>
          <view class="copy" @click="copy">复制</view>
        </view>

        <view class="brank_name"> {{ conf.bank_name }} </view>

        <view class="info">
          <view class="let">
            <view class="name">收款人</view>
            <view class="des">{{ conf.bank_card_name }}</view>
          </view>
          <view class="rig">
            <view class="name">开户行</view>
            <view class="des">{{ conf.bank_branch_name }}</view>
          </view>
        </view>
      </view>
    </view>
    <view class="pof safe-area-inset-bottom">
      <view class="btn"><view @click="file">上传凭证</view></view>
    </view>
  </view>
  <Shenhe v-else-if="shenheStatus == 1"></Shenhe>
</template>

<script>
import Shenhe from "@/components/shenhe/shenhe";
import { payOfflineSetting } from "@/api/pay";

export default {
  components: { Shenhe },

  data() {
    return {
      list: [],
      index: 1,
      order_id: "",
      conf: {
        alipay_qrcode: "",
        bank_branch_name: "",
        bank_card_id: "",
        bank_card_name: "",
        bank_name: "",
        open_alipay: 1,
        open_bank: 1,
        open_wechat: 1,
        wechat_qrcode: ""
      }
    };
  },

  async onLoad(opi) {
    this.order_id = opi.orderId;
    this.$utils.hideShareMenu();

    const res = await payOfflineSetting();

    if (!res.code) {
      const list = [];
      let { conf } = res.data,
        { open_alipay, open_bank, open_wechat } = conf;
      this.conf = conf;
      if (open_wechat == 1) list.push({ name: "微信转账", id: 1 });
      if (open_alipay == 1) list.push({ name: "支付宝转账", id: 2 });
      if (open_bank == 1) list.push({ name: "银行卡转账", id: 3 });
      this.list = list;
    }
  },

  methods: {
    copy() {
      uni.setClipboardData({
        data: this.conf.bank_card_id
      });
    },

    file() {
      this.$u.throttle(() => {
        let { order_id, index } = this;
        uni.navigateTo({
          url: `/other/offlinePayment/file?order_id=${order_id}&type=${index}`
        });
      }, 500);
    }
  }
};
</script>

<style lang="scss" scoped>
.page {
  background: #f2f2f2;
  min-height: 100vh;
  padding-top: 44rpx;
}

.content {
  margin: 0 24rpx;
  background: #fff;
  border-radius: 20rpx;
}

.menu {
  display: flex;
  margin-bottom: 60rpx;

  .menuItem {
    position: relative;
    flex: 1;
    height: 64rpx;
    transition: 0.3s linear;

    &:last-of-type .name {
      border-radius: 0 20rpx 0 0;
    }

    &:first-of-type .name {
      border-radius: 20rpx 0 0 0;
    }

    .name {
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 28rpx;
      color: #8c8c8c;
      transition: 0.3s linear;
      background: #f8f8f8;
    }

    &.active {
      .name {
        height: 84rpx;
        font-weight: bold;
        font-size: 30rpx;
        color: #262626;
        background: #fff;
        border-radius: 20rpx 20rpx 0 0;
      }
    }
  }
}

.imgdes {
  padding: 60rpx 0;
  text-align: center;
  font-size: 24rpx;
  color: #8c8c8c;
}

.img {
  padding: 0 92rpx;

  image {
    display: block;
    width: 100%;
  }
}

.list {
  padding: 0 24rpx 60rpx;
}

.bank_card {
  display: flex;
  align-items: center;

  .number {
    font-size: 36rpx;
    font-weight: bold;
    color: #262626;
  }

  .copy {
    margin-left: 24rpx;
    padding: 2rpx 12rpx;
    background: #f2f2f2;
    border-radius: 32px;
    background: #f2f2f2;
  }
}

.list {
  .brank_name {
    padding: 10rpx 0 24rpx;
  }

  .info {
    display: flex;
    .let {
      width: 33.33%;
    }

    .rig {
      flex: 1;
      overflow: hidden;
    }

    .name {
      padding-bottom: 6rpx;
      color: #8c8c8c;
      font-size: 24rpx;
    }

    .des {
      color: #262626;
      font-size: 26rpx;
      font-weight: bold;
    }
  }
}

.pof {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;

  .btn {
    padding: 12rpx 36rpx;

    view {
      height: 76rpx;
      line-height: 76rpx;
      overflow: hidden;
      text-align: center;
      background: linear-gradient(90deg, #f22407 0%, #f84d17 100%);
      border-radius: 32px;
      font-size: 26rpx;
      color: #fff;
    }
  }
}
</style>
